#栈
input_list = [1,2,3,4,5,6,7,8,9,0]
#1为栈底，0为栈顶
class Stack:
    def __init__(self):
        self.items=[]
    def push(self, data):
        self.items.append(data)
    def pop(self):
        if not self.items:
            return None
        else:
            return self.items.pop()
    def peek(self): #查看栈顶元素
        return(self.items[-1])
    def is_empty(self):
        return self.items == []
    def size(self):
        return len(self.items)#返回栈顶长度

stack = Stack()
stack.push(1)
stack.push(2)
stack.push(3)
print("stack.pop()="+str(stack.pop()))
print("stack.peek()="+str(stack.peek()))
print("stack.size()="+str(stack.size()))
print("stack.is_empty()="+str(stack.is_empty()))
def input(input): #把列表中的元素一个一个压入栈中
    stack_input = Stack()
    for element in input:
        stack_input.push(element)
    return stack_input
def output(stack_output): #把列表中的元素一个一个弹出
    while not stack_output.is_empty():
        print(stack_output.pop())
stack_output=input(input_list)
output(stack_output)
print(stack_output.items)
from collections import deque
input_queue= [1,2,3,4,5,6,7,8,9]
class SimpleQueue:
    def __init__(self):
        self.items=deque([])
    def is_empty(self):
        return self.items == deque([])
    def enqueue(self,data):
        self.items.append(data)
    def dequeue(self):
        if self.items != deque([]):
            return self.items.popleft()
        else:
            return deque([])
    def size(self):
        return len(self.items)
que = SimpleQueue()
que.enqueue(1)
que.enqueue(2)
que.enqueue(3)
que.dequeue()
print(que.is_empty())
print(que.size())
def input(input):#把所有元素一个一个入队
    queue = SimpleQueue()
    for element in input:
        queue.enqueue(element)
    return queue
def output(queue):#把所有元素一个一个出队
    while not queue.is_empty():
        print(queue.dequeue())

queue=input(input_queue)
output(queue)